package cn.edu.neusoft.wuguangsheng.flowerimpression.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.flowerimpression.R;
import cn.edu.neusoft.wuguangsheng.flowerimpression.adapter.EmptyRecyclerView;
import cn.edu.neusoft.wuguangsheng.flowerimpression.adapter.UserFKnowAllCollectionAdapter;
import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.AllCollectionKnowBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.listener.ListListener;
import cn.edu.neusoft.wuguangsheng.flowerimpression.model.GetAllKnowCollectionListModel;

public class AllKnowCollectionActivity extends BaseActivity {
    private List<AllCollectionKnowBean> items;
    EmptyRecyclerView all_know_shocang_rv;
    private boolean up = false;
    View all_konw_shoucang_emptyview;
    ImageView all_know_shoucang_fh;

    @Override
    void initView() {
        setLayout_file(R.layout.activity_all_know_collection);

        all_know_shocang_rv = (EmptyRecyclerView)findViewById(R.id.all_know_shoucang_rv);
        all_konw_shoucang_emptyview = (View)findViewById(R.id.all_konw_shoucang_emptyview);
        all_know_shoucang_fh = (ImageView)findViewById(R.id.all_know_shoucang_fh);
        GetAllKnowCollectionListModel getAllKnowCollectionListModel=new GetAllKnowCollectionListModel();
        getAllKnowCollectionListModel.getAllKnowCollectionList(getid(), new ListListener<AllCollectionKnowBean>() {
            @Override
            public void onResponse(List<AllCollectionKnowBean> list) {
                LinearLayoutManager linearLayoutManager=new LinearLayoutManager(AllKnowCollectionActivity.this);
                linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                all_know_shocang_rv.setLayoutManager(linearLayoutManager);
                items=list;
                UserFKnowAllCollectionAdapter userFKnowAllCollectionAdapter=new UserFKnowAllCollectionAdapter(AllKnowCollectionActivity.this,items,R.layout.allcollectionknow_item);
                all_know_shocang_rv.setAdapter(userFKnowAllCollectionAdapter);
                all_know_shocang_rv.setItemAnimator(new DefaultItemAnimator());
                all_know_shocang_rv.setEmptyView(all_konw_shoucang_emptyview);
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }

    @Override
    void initEvent() {
        all_know_shoucang_fh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }

    @Override
    void initDate() {

    }

    @Override
    protected void onPause() {
        super.onPause();
        up = true;

    }

    @Override
    protected void onResume() {
        super.onResume();
        if (up) {
            initView();
            initEvent();
            initDate();
            up = false;
        }
    }
}
